#include <Engine/StdAfx.h>
#include <Engine/SceneGraph/SpatialObject.h>
#include <Engine/IScene.h>

using namespace fastbird;

//----------------------------------------------------------------------------
SpatialObject::SpatialObject()
	:mDistToCam(-1.f)
{
}

//----------------------------------------------------------------------------
SpatialObject::~SpatialObject()
{
	mDestructing = true;
	for each(auto scene in mScenes)
	{
		scene->DetachObject(this);
	}
}

//----------------------------------------------------------------------------
void SpatialObject::SetPos(const Vec3& pos)
{
	mBoundingVolumeWorld->SetCenter(mBoundingVolume->GetCenter() + pos);
	mTransformation.SetTranslate(pos);
}

//----------------------------------------------------------------------------
void SpatialObject::SetRot(const Quat& rot)
{
	mTransformation.SetRotation(rot);
}

//----------------------------------------------------------------------------
const Vec3& SpatialObject::GetPos() const
{
	return mTransformation.GetTranslation();
}

//----------------------------------------------------------------------------
const Quat& SpatialObject::GetRot() const
{
	return mTransformation.GetRotation();
}

//----------------------------------------------------------------------------
void SpatialObject::SetDistToCam(float dist)
{
	mDistToCam = dist;
}

//----------------------------------------------------------------------------
float SpatialObject::GetDistToCam() const
{
	return mDistToCam;
}